package com.shu.controller;

import com.shu.shiro.CustomAuthenticationToken;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by shu on 2017/8/17.
 */
@RestController
@RequestMapping("/user")
public class LoginController {

    @RequestMapping(value = "/login",method = RequestMethod.POST)
    public Object login(@RequestParam String userName,@RequestParam String password) throws Exception{
        CustomAuthenticationToken token = new CustomAuthenticationToken(userName,password,true,null,null);
        Subject currentUser = SecurityUtils.getSubject();

        currentUser.login(token);

        return "denglu";
    }

    

}
